<!DOCTYPE html>
<html lang="en">
<head>
    <title>佳怡供应链金融</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">
    <link rel="stylesheet" href="lib/weui.min.css">
    <link rel="stylesheet" href="css/jquery-weui.css">
    <link rel="stylesheet" href="demos/css/demos.css">
    <link rel="stylesheet" href="font/fontscss/iconfont.css">
    <link rel="stylesheet" href="css/common.css">
    <style type="text/css">
        .content-header {
            width: 100%;
            background-color: #FF9461;
            position: relative;
            z-index: 10;
            color: #fff;
        }

        #pro_name {
            font-size: 16px;
            padding-top: 0.7rem;
            padding-left: 15%;
        }

        #one_pri {
            font-size: 32px;
        }

        .ljsy {
            pont-size: 12px;
            opacity: 0.6;
        }

        .tzze {
            padding-top: 1.5rem;
            font-size: 16px;
        }

        .time {
            text-align: center;
        }

        .time-left {
            width: 50%;
            display: inline-block;
            line-height: 1.5rem;
        }

        .span1 {
            font-size: 14px;
        }

        .span2 {
            font-size: 12px;
            opacity: 0.6;
        }

        .time-left span {
            display: block;
        }

        .time-right {
            width: 48%;
            float: left;
            line-height: 1.5rem;
        }

        .time-right span {
            display: block;
        }

        .content-info ul li {
            height: 3rem;
            line-height: 3rem;
            border-bottom: 1px solid #E6E2E2;
            font-size: 16px;
        }

        .content-info ul li span {
            color: #FF9461
        }

        .content-info .content-orl {
            width: 10%;
            display: inline-block;
        }

        .content-info .content-title {
            width: 59%;
            display: inline-block;
        }

        .content-info .content-info {
            width: 18%;
            display: inline-block;
        }

        .content-info .content-orl {
            background-image: url("demos/images/rol.png");
        }

        .comment {
            border: 1px solid #ABA1A1;
            border-radius: 1rem;
            width: 64%;
            position: relative;
            left: 5rem;
            margin-top: 1rem;
            margin-bottom: 1rem;
        }

        .tbtop {
            padding-left: 1rem;
            color: #FF9461;
        }

        .tbtop span {
            display: block;
        }

        .pz {
            margin-left: 1rem;
        }

        .icon_back {
            position: absolute;
            left: -1rem;
            top: 0.9rem;
            width: 0.5rem;
            height: 1.0rem;
            background: url(./images/icon-back.png);
            background-size: 0.5rem 1em;
            vertical-align: middle;
        }

        .weui-cell__ft {
            width: 65%;

        }

        .weui-cell__bd {
            width: 35%;
        }
    </style>
    <script src="lib/jquery-2.1.4.js"></script>
    <script type='text/javascript' src='js/swiper.js' charset='utf-8'></script>

</head>

<body>
<header>
    <div class="weui-row weui-no-gutter">
        <div class="weui-col-33" id="back_icon">
            <a href="javascript:history.go(-1)" class="icon pull-right"><i class="icon_back"></i></a>
        </div>
        <div class="weui-col-33">产品投资详情</div>
        <div class="weui-col-33" id="ligin_icon">
            <!-- <a href="login.html" class="icon pull-right"><i class="iconfont icon-wode"></i></a> -->
        </div>
    </div>
</header>
<div class="weui-cells">


</div>

</body>
<script src="js/circleProgress.js"></script>
<script src="js/jquery-weui.js"></script>
<script src="js/reg.js"></script>
<script type="text/javascript">
    $(function () {

        var str = "";
        var id = localStorage.getItem("sq_id");
        var proId = localStorage.getItem("sq_proId");
        $.ajax({
            type: "POST",
            url: "productInvestment/getSinglecostInfo",
            data: {id: id},   //传递输入框中的值
            success: function (val) {
                var investment_start_time = val.investment_start_time;
                var id = val.id;
                var status = val.investment_status;//投资状态
                var end_time = val.end_time;
                var application_status1 = val.application_status;//提现状态
                var type = val.type;
                var withdraw_time = val.withdraw_time;


                var yield = val.yield;
                console.log(val);
                str += "<div class=\"weui-cell\">"
                str += "<div style='margin-left: 5%;float: left'> <a href=\"javascript:;\"onclick=\"queren('" + id + "','" + status + "','" + end_time + "','" + withdraw_time + "','" + yield+"')\" class=\"weui-btn weui-btn_primary\">确认</a></div>"
                str += "<div style='margin-left: 2%;float: left'> <a href=\"javascript:;\"onclick=\"tixian('" + id + "','" + status + "','" + application_status1 + "','" + type + "','" + val.qrsyl + "','" + val.apply_time + "')\" class=\"weui-btn weui-btn_primary\">提现确认</a></div>"
                str += "<div style='margin-left: 2%;float: left'> <a href=\"javascript:;\"onclick=\"Details('" + id + "')\" class=\"weui-btn weui-btn_primary\">查看计提月份</a></div>"

                str += "</div>"
                // str+="<div class=\"weui-cells weui-cells_form\">"
                str += " <form method=\"post\" id=\"frmInfo\">"
                str += "<div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>会员姓名</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\"id=\"username\">" +
                    val.username +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>联系电话</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\"id=\"phone\">" +
                    val.phone +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>产品名称</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.product_name +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>合同编号</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.bh2 +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>会员代码</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.codes2 +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>投资开始时间</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.investment_start_time2 +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>投资结束时间</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.end_time +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>投资金额</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.investment_amount +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>投资收益</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.investment_profit +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>投资收益率(%)</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.qrsyl +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>投资状态</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    (val.investment_status == 0 ? "未确认" : (val.investment_status == 1 ? "已确认" : (val.investment_status == 2 ? "审核通过" : (val.investment_status == 3 ? "驳回" : (val.investment_status == 4 ? "已确认待审核" : ""))))) +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>提现状态</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    (val.application_status == 0 ? "未申请" : (val.application_status == 1 ? "待确认" : (val.application_status == 2 ? "已确认" : (val.application_status == 3 ? "审核通过" : (val.application_status == 4 ? "驳回" : (val.application_status == 5 ? "已确认待审核" : "")))))) +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>开户名</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.account_name +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>账号</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.account_number +
                    "        </div>" +
                    "    </div>" +
                    "    <div class=\"weui-cell\">" +
                    "        <div class=\"weui-cell__bd\">" +
                    "            <p>开户行</p>" +
                    "        </div>" +
                    "        <div class=\"weui-cell__ft\">" +
                    val.bank_account +
                    "        </div>" +
                    "    </div>"

                str += "</form>"
                //str+="</div>"
                $(".weui-cells").append(str);

            }
        });
    });
    function isNull(str) {
        if (str == null || str == "" || str == "undefined") {
            return '';
        } else {
            return str;
        }
    }
    function queren(id, status1, end_time1, withdraw_time, yield) {
        var str = CurentTime();
        var format = function (time, format) {
            var t = new Date(time);
            var tf = function (i) {
                return (i < 10 ? '0' : '') + i
            };
            return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) {
                switch (a) {
                    case 'yyyy':
                        return tf(t.getFullYear());
                        break;
                    case 'MM':
                        return tf(t.getMonth() + 1);
                        break;
                    case 'mm':
                        return tf(t.getMinutes());
                        break;
                    case 'dd':
                        return tf(t.getDate());
                        break;
                    case 'HH':
                        return tf(t.getHours());
                        break;
                    case 'ss':
                        return tf(t.getSeconds());
                        break;
                }
            })
        }

        if (str > end_time1) {
            $.toast('时间已结束');
        } else if (status1 == 1) {
            $.toast('数据已经确认');
        } else if (status1 == 2) {
            $.toast('审核已通过');
        } else {
            $.modal({
                title: "Hello",
                text: "" +
                "<span style='  margin-left: 25px;'><font color='red' >*</font>合同编号：</span><span  text-align: left'><input style='width: 90px;height: 25px; ' type='text' id='bh'  ><br><br></span>  " +
                " <span  ><font color='red' >*</font>投资结束时间：</span><span ><input    style='width: 90px;height: 25px; z-index: 9999;'  type='text' id='withdraw_time'><br><br></span> " +
                " <span style='  margin-left: 10px;'><font color='red' >*</font>投资收益率：</span><span text-align: left'><input    style='width: 90px;height: 25px; '  type='text' id='qrsyl'  ><br><br></span> " +
                " <span style='  margin-left: 30px;'><font color='red' >*</font>会员代码: </span><span text-align: left'><input     style='width: 90px;height: 25px;' type='text' id='codes'  ><br><br></span> ",
                buttons: [
                    {
                        text: "确认并申请", onClick: function () {
                        if ($("#bh").val() == "" || $("#bh").val() == null) {
                            $.toast("合同编号不可为空");
                        } else if ($("#withdraw_time").val() == "" || $("#withdraw_time").val() == null) {
                            $.toast("结束时间不可为空");
                        } else if ($("#qrsyl").val() == "" || $("#qrsyl").val() == null) {
                            $.toast("投资收益率不可为空");
                        } else if ($("#codes").val() == "" || $("#codes").val() == null) {
                            $.toast("会员代码不可为空");
                        } else {
                            updateMember(id, yield, $("#bh").val(), $("#withdraw_time").val(), $("#qrsyl").val(), $("#codes").val())

                        }
                    }
                    },
                    {
                        text: "返回", onClick: function () {
                        console.log(2)
                    }
                    },

                ]
            });
        }


        $("#qrsyl").val(yield);
        $("#withdraw_time").calendar({
            value: [format(end_time1, "yyyy-MM-dd")],
            minDate: [format(CurentTime(), "yyyy-MM-dd")],
        });
        $("#withdraw_time").val(end_time1);


    }


    //确认
    function updateMember(id, yield, bh, withdraw_time, qrsyl, codes) {
        /*var bh=$("#bh").val();
         var syls=$("#qrsyl").val();
         var withdraw_time=$("#withdraw_time").val();
         var codes=$("#codes").val();*/

        if (qrsyl > 100) {
            $.toast("投资收益率不能大于100% ");
        } else {

            $.confirm("您确定要确认吗?", "确定确认?", function () {
                $.ajax({
                    type: "POST",
                    url: 'productInvestment/confirm',
                    data: {
                        bh: bh, syls: qrsyl, withdraw_time: withdraw_time, codes: codes, id: id, ysyl: yield
                    },
                    success: function (msg) {
                        console.info(msg);
                        if (msg) {
                            location.href = "investConfirm.html"
                            $.toast('确认成功');

                        }
                    }
                });
            }, function () {

            });


        }

    }
    function tixian(id, status1, application_status1, type, qrsyl, apply_time) {
        var str = CurentTime();
        if (status1 == 0 || status1 == 3) {
            $.toast('数据未确认,不可提现！');
        } else if (application_status1 == 0) {
            $.toast('数据未提出申请,不可提现！');
        } else if (application_status1 == 2) {
            $.toast('提现申请已确认！');
        } else {

            $.modal({
                title: "Hello",
                text: "" +
                "<span style='   margin-left: 25px;'><font color='red' >*</font>投资收益率：</span><span  text-align: left'><input style='height: 25px; ' type='text' id='tjsyl'  ><br><br></span>  " +
                " <span  ><font color='red' >*</font>投资提现（结束）时间：</span><span ><input    style='height: 25px; z-index: 9999;'  type='text' id='withdraw_time'><br><br></span> ",
                buttons: [
                    {
                        text: "确认并申请", onClick: function () {
                        if ($("#tjsyl").val == "" || $("#tjsyl").val == null) {
                            $.toast("投资收益率不可为空")
                        } else if ($("#withdraw_time").val == "" || $("#withdraw_time").val == null) {
                            $.toast("投资提现（结束）时间不可为空")
                        } else {
                            txConfirm(id, status1, application_status1, type)
                        }

                    }
                    },
                    {
                        text: "返回", onClick: function () {
                        console.log(2)
                    }
                    },

                ]
            });

            $("#tjsyl").val(qrsyl);
            $("#withdraw_time").val(apply_time);
            if (type == 1) {
                $("#tjsyl").attr("readonly", "readonly")
                $("#withdraw_time").attr("disabled", "disabled")
                $("#withdraw_time").calendar({
                    inputReadOnly: true
                });

            }
            $("#withdraw_time").calendar({});
        }


    }

    //提现确认
    function txConfirm(id, status1, application_status1, type) {

        var syls = $("#tjsyl").val();
        var withdraw_time = $("#withdraw_time").val();
        /*var pName = $("#product_name").val();
         var money = $("#investment_amount").val();
         var profit = $("#investment_profit").val();
         var userid = $("#user_id").val();
         var apply_time = $("#apply_time").val();
         var ysyl=$("#qrsyl").val();*/
        if (syls > 100) {
            $.toast("投资收益率不能大于100% ");
        } else {
            $.confirm("您确定要确认吗?", "确定确认?", function () {
                $.ajax({
                    type: "POST",
                    url: 'productInvestment/cashfirm',
                    data: {id: localStorage.getItem("sq_id"), withdraw_time: withdraw_time, syls: syls},
                    success: function (msg) {
                        console.info(msg);
                        if (msg) {
                            $.toast('确认成功');
                            location.href = "investConfirm.html";


                        }
                    }
                });
            }, function () {

            });
        }

    }

    function Details(id) {

        location.href = "details.html";


    }

    function CurentTime(befour, after) {
        var now = new Date();
        if (befour != null) {
            now.setDate(now.getDate() - befour);
        }
        if (after != null) {
            now.setDate(now.getDate() + after);
        }
        var year = now.getFullYear(); // 年
        var month = now.getMonth() + 1; // 月
        var day = now.getDate(); // 日
        //var ss = now.getSeconds();
        var clock = year + "-";
        if (month < 10)
            clock += "0";
        clock += month + "-";
        if (day < 10)
            clock += "0";
        clock += day + " ";
        return (clock);
    }
    function browser(pb) {
        pb.open();
    }
    $(function () {
        $("#img0").on('click', function () {
            pb1.open();
        })
    })
</script>
<script src="js/web/checkLogin.js"></script>
</html>